//
//  LWHttpTool.m
//  豆瓣
//
//  Created by 刘伟 on 16/7/7.
//  Copyright © 2016年 刘伟. All rights reserved.
//

#import "LWHttpTool.h"
#import "AFNetworking.h"
@implementation LWHttpTool
+(void)getdata:(NSString*)url andPara:(NSDictionary*)dict andCompleteBlock:(ArrayBlock)successBlock andFail:(FailError)error{
  AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc]initWithSessionConfiguration:nil];
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];

    [manager GET:url parameters:dict progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSDictionary * dict = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil];
        successBlock(dict);
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull errors) {
        error(errors);
    }];

}
+(void)postdata:(NSString*)url andPara:(NSDictionary*)dict andCompleteBlock:(ArrayBlock)successBlock andFail:(FailError)error{
    AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc]initWithSessionConfiguration:nil];
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    [manager POST:url parameters:dict progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSDictionary * dict = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil];
        successBlock(dict);
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull errors) {
          error(errors);
    }];

}


@end
